/*
 * List.cpp
 *
 *  Created on: May 11, 2012
 *      Author: pleun
 */

#include "List.h"

List::List() {
	pipelines = new vector<Pipeline*> ();
}

List::~List() {
		for (vector<Pipeline*>::iterator iter = pipelines->begin();
				iter != pipelines->end(); ++iter) {
			delete *iter;
		}
	delete pipelines;
}

void List::addNewPipeline() {
	//Er is de parser een | gevonden. Dit betekend dat er een nieuwe pipeline aangemaakt moet worden.
	cout << "New pipeline" << endl;
	pipelines->push_back(new Pipeline());
}

void List::addNewCommandLineToPipeline() {
	cout << "    New commandline" << endl;
	Commandline* cl = new Commandline();
	pipelines->back()->addNewCommandline(cl);
}

void List::addnewWordToCommandLine(string commandText) {
	cout << "         New word " << commandText << endl;
	pipelines->back()->addCommandTextToCommandline(commandText);
}

Pipeline* List::getPipeline() {
	return pipelines->back();
}

void List::executeAll() {
	for (vector<Pipeline*>::iterator iter = pipelines->begin(); iter
			!= pipelines->end(); ++iter) {
		(*iter)->ExecutePipeLine();
	}
}

